<html>
<#include "../common/header.ftl" />

<script>

	function unlock(id){
	$.get("recruit", {
		method : "status",
		key: "1",
		id : id
	}, function(res) {
		let data = JSON.parse(res)
		console.log('succ',data)
		if(data.code === 0){
			tip(data.msg)
		$("#box_"+id).removeClass("list-group-item-danger list-group-item-warning").addClass("list-group-item-success");
		$("#status_"+id).text("ACCEPTED")
		$("#unlock_"+id).attr("style","display:none")
		$("#lock_"+id).attr("style","display:inline")
		}
		else{
			tip(data.msg)
		}
	})
}
function lock(id){
	$.get("recruit", {
		method : "status",
		key: "2",
		id : id
	}, function(res) {
		let data = JSON.parse(res)
		console.log('succ',data)
		if(data.code === 0){
			tip(data.msg)
			$("#box_"+id).removeClass("list-group-item-success list-group-item-warning").addClass("list-group-item-danger");
			$("#status_"+id).text("REFUSED")
			$("#unlock_"+id).attr("style","display:inline")
			$("#lock_"+id).attr("style","display:none")
		}else
			{
			tip(data.msg)
			}
		
	})
}
function tip (msg){
	$("#warn").text(msg)
	$("#modal-282051").click()
}
		</script>

<style>
@media screen and (max-width: 600px) {
    .hid {
		display:none
    }
}
</style>
</head>

<#if Session.user ?? && user.role==1>
<body style="margin-left: 200px">

	<div id="wrapper" class="toggled">
		<#include "../common/nav.ftl" />

		<#include "../modal/tips.ftl" />
	</div>
	<#else>
</#if>


<div class="container">

	<a id="modal-282051" href="#modal-warns" style="display: none"
		role="button" class="" data-toggle="modal"></a>
	<div class="row clearfix">
		<div class="col-md-12 column">


			<#include "../common/bread.ftl"/>
			<blockquote>
				<h2>新生列表</h2>
				<hr/>
				<#assign sum1 = 0,sum2 = 0,sum3=0,sum4=0/>
				<#if lists ??>
					<#list lists as item>
						<#if item.major == "计算机科学与技术">
							<#assign sum1 = sum1 + 1>
							<#elseif item.major == "物联网">
							<#assign sum2 = sum2 + 1>
							<#elseif item.major == "软件工程">
							<#assign sum3 = sum3 + 1>
							<#elseif item.major == "信息安全">
							<#assign sum4 = sum4 + 1>
						</#if>
					</#list>
				</#if> 
				
				<#if sum1 ??><a class="btn btn-info btn-sm" href="recruit?method=type&key=a">计算机科学与技术：<span class="label label-primary">${sum1}</span></a></#if>
				<#if sum2 ??><a class="btn btn-info btn-sm" href="recruit?method=type&key=b">物联网：<span class="label label-primary">${sum2}</span></a></#if>
				<#if sum3 ??><a class="btn btn-info btn-sm" href="recruit?method=type&key=c">软件工程：<span class="label label-primary">${sum3}</span></a></#if>
				
				<#if sum4 ??><a class="btn btn-info btn-sm" href="recruit?method=type&key=d">信息安全：<span class="label label-primary">${sum4}</span></a> 
				<a class="btn btn-danger btn-sm" href="recruit">总计：<span class="label label-warning">${sum4+sum3+sum2+sum1}</span></a>
				<a class="btn btn-success btn-sm" href="recruit?method=type&key=all">通过：<span class="label label-primary">${sum4+sum3+sum2+sum1}</span></a>
				
				</#if>
				
				<a class="btn btn-success btn-sm" style="font-weight:900" href="recruit?method=out">导出(ACCEPTED)XML </a>
				
			</blockquote>
			<div class="list-group ">
				<#if lists ??>
					 <#list lists as item> <a id="box_${item.id }"
						class="list-group-item 
						<#if item.status = 0>
						list-group-item-warning
						<#elseif item.status ==1>
						list-group-item-success
						<#elseif item.status ==2>
						list-group-item-danger 
						</#if>
						">
						<h4 class="list-group-item-heading">
							<div
								<#if item.status == 2 > style="color:red" </#if> >
								<blockquote  <#if item.sex=='女'> style="color:#FFC0CB" </#if> >${item.name }<#if item.sex=='男'>♂<#else>♀</#if>(<i style="color:#808080"> [<#if item.sid == '1'>2018<#elseif item.sid =='2' >2017<#elseif item.sid =='17' >2017<#elseif item.sid =='18' >2018<#else>${item.sid }</#if>]${item.major }</i>)</blockquote>
								<p style="margin:15px">
								<span class="label label-info"> 手机：${item.phone } </span>
								 </p>
								<p style="margin:15px">
								<span class="label label-info"> QQ：${item.qq } </span>
								</p>
								<div class="panel panel-info" style="padding:10px">${item.note }</div>
								</p>
							</div>
						</h4>
						
						<h4 class="hid">
							<span class="label label-warning">状态：</span> 
							<span
								class="label label-primary">
								<span id="status_${item.id }"> <#if item.status == 0 >待审核<#elseif item.status == 1 >ACCEPTED<#else>REFUSED</#if></span>
								</span> <span class="label label-primary">${item.createtime?string("yyyy-MM-dd HH:mm:ss")}</span>
								 <span class="label label-primary">${item.ip}</span>
						</h4> <span style="float: left"> <a class="btn btn-primary"
							type="button"> <em class="glyphicon glyphicon-align-left"></em>
								操作：
						</a> <#if item.status == 2> 
							<a id="unlock_${item.id }" class="btn btn-success" onclick="unlock(${item.id })">ACCEPT</a> 
							<a id="lock_${item.id }" style="display:none" class="btn btn-danger" onclick="lock(${item.id })">REFUSE</a>
							<#elseif item.status == 1> 
							<a id="unlock_${item.id }" style="display:none" class="btn btn-success" onclick="unlock(${item.id })">ACCEPT</a> 
							<a id="lock_${item.id }"  class="btn btn-danger" onclick="lock(${item.id })">REFUSE</a>
							<#else>
							<a id="unlock_${item.id }"  class="btn btn-success" onclick="unlock(${item.id })">ACCEPT</a> 
							<a id="lock_${item.id }"  class="btn btn-danger" onclick="lock(${item.id })">REFUSE</a>
							
							 </#if>
					</span>
						<hr />
					</a> </#list> </#if>

				</div>

			<#--
			<table class="table table-striped">
				<thead>
					<tr>
						<th>编号</th>
						<th>名称</th>
						<th>作者</th>
						<th>发布人</th>
						<th>类型</th>
						<th>关键字</th>
						<th>点击量</th>
						<th>创建时间</th>
						<th colspan="2">操作</th>
					</tr>
				</thead>
				<tbody>
					<#list lists.data as item> <#if
						Session.user.role ?? &&
						Session.user.role==0> <#if
						item.newsstatus==1>
						<tr class="success">
							<td>${item.newsId }</td>
							<td>${item.newsName }</td>
							<td>${item.newsAuthor }</td>
							<td>${item.publisher  }</td>
							<td><#if item.newsType ==1>科普</#if> <#if item.newsType
								==2>体育</#if> <#if item.newsType ==3>财经</#if> <#if item.newsType
								==4>生活</#if></td>
							<td>${item.newsKeywords!"" }</td>
							<td>${item.newsClick }</td>
							<td>${item.createtime }</td>
							<td><a href="news?method=detail_page&id=${item.newsId }">查看</a>
								<#if Session.user.role ?? && Session.user.role == 1 > <a
								href="#">删除</a> </#if></td>
						</tr>
						</#if> <#else> <#if item.newsstatus==0>
					<tr class="warning">
					</#if> <#if item.newsstatus==1>
					<tr class="success">
					</#if> <#if item.newsstatus==2>
					<tr style="background: rgba(255, 69, 0, 0.4)">
					</#if>
					<td>${item.newsId }</td>
					<td>${item.newsName }</td>
					<td>${item.newsAuthor }</td>
					<td>${item.publisher }</td>
					<td><#if item.newsType==1>科普</#if> <#if item.newsType==2>体育</#if>
						<#if item.newsType==3>财经</#if> <#if item.newsType==4>生活</#if></td>
					<td>${item.newsKeywords!"" }</td>
					<td>${item.newsClick }</td>

					<td><#if item.newsstatus==1>已发布</#if> <#if item.newsstatus==0>待审核</#if>
						<#if item.newsstatus==2>
						<span style="color: red;"><b>已废弃</b></span></#if></td>

					<td>${item.createtime }</td>

					<td><a href="news?method=detail_page&id=${item.newsId }">查看</a>
						<#if Session.user.role ?? && Session.user.role==1 > <a
								href="#">删除</a> </#if></td>
					</tr></#if> </#list>
				</tbody>
			</table>
			--> 
		</div>
	</div>
</div>
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">
                    提醒
                </h4>
            </div>
            <div id="modal-body" class="modal-body">
            </div>
            <div class="modal-footer">
                <button onclick="javascript:document.getElementById('notice').pause()" type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button onclick="location.reload()" type="button" class="btn btn-primary">查看</button>
            </div>
        </div>
    </div>
      <audio id="notice" loop='loop'>
        <source src="mp3/song.mp3" type="audio/mpeg"/>
    </audio>
<script src="static/js/3.1.0bootstrap.min.js"></script>
<script>
    var websocket = null;
    if ('WebSocket' in window) {
        websocket = new WebSocket('ws://39.106.2.56/iotlab/webSocket');
    } else {
        alert('该浏览器不支持');
    }
    websocket.onopen = function (event) {
        console.log('建立连接');
    }
    websocket.onclose = function (event) {
        console.log('关闭连接');
    }
    websocket.onmessage = function (ev) {
        console.log('收到消息：' + ev.data);
        //弹窗提醒
        $('#modal-body').text(ev.data)
        $('#myModal').modal('show');
        $('#notice').trigger('play');
    }
    websocket.onerror = function (ev) {
        alert('webSocket发生错误');
    }
    window.onbeforeunload = function (ev) {
        websocket.close();
    }
</script>
</body>
</html>